<template>
  <tr>
    <td><input type="checkbox" v-model="checked" /> <span></span></td>
    <td>{{ name }}</td>
    <td>{{ price }}</td>
    <td>
      <button @click="reduce">-</button>
      {{ num }}
      <button @click="add">+</button>
    </td>
    <td>{{money}}</td>
    <td>
      <button @click="del">删除</button>
    </td>
  </tr>
</template>

<script>
export default {
  props: ["name", "price", "num", "checked", "index"],
  methods: {
    add() {
      this.$emit("jiayi", this.index, 1);
    },
    reduce() {
      this.$emit("jianyi", this.index, 1);
    },
     del() {
      this.$emit("shanchu", this.index);
    },
  },
  computed: {
      money(){
          return this.price * this.num
      }
  }
};
</script>

<style>
</style>